<script>
    $(function () {
        $("#clear-empresas").select2({
            placeholder: "Empresas",
            allowClear: true
        });
        $("#clear-divisiones").select2({
            placeholder: "Division",
            allowClear: true
        });
        $("#clear-modulos").select2({
            placeholder: "Modulos",
            allowClear: true
        });
        $("#clear-sub-modulos").select2({
            placeholder: "Sub-Modulos",
            allowClear: true
        });
        $("#clear-materiales").select2({
            placeholder: "Materiales",
            allowClear: true
        });
    });
</script>
<script>
    $(document).ready(function () {
        $('#clear-empresas').change(function () {
            var e_empresa_id = {
                name: $('#clear-empresas').val()
            };
            $.ajax({
                url: "<?= base_url('divisiones/jsonlist') ?>",
                type: 'POST',
                dataType: 'json',
                data: e_empresa_id,
                success: function (msg) {
                    
                    var sc = '';
                    sc += '<option value=""></option>';
                    $.each(msg, function (key, val) {
                        sc += '<option value="' + val.d_division_id + '">' + val.d_nombre + '</option>';
                    });
                    $("#clear-divisiones option").remove();
                    $("#clear-modulos option").remove();
                    $("#clear-sub-modulos option").remove();
                    $("#clear-materiales option").remove();
                    $("#clear-divisiones").append(sc);
                }
            });
        });
    });
    $(document).ready(function () {
        $('#clear-divisiones').change(function () {
            var d_division_id = {
                name: $('#clear-divisiones').val()
            };
            $.ajax({
                url: "<?= base_url('modulos/jsonlist') ?>",
                type: 'POST',
                dataType: 'json',
                data: d_division_id,
                success: function (msg) {
                    var sc = '';
                    sc += '<option value=""></option>';
                    $.each(msg, function (key, val) {
                        sc += '<option value="' + val.m_modulo_id + '">' + val.m_nombre + '</option>';
                    });
                    $("#clear-modulos option").remove();
                    $("#clear-sub-modulos option").remove();
                    $("#clear-materiales option").remove();
                    $("#clear-modulos").append(sc);
                }
            });
        });
    });
    $(document).ready(function () {
        $('#clear-modulos').change(function () {
            var m_modulo_id = {
                name: $('#clear-modulos').val()
            };
            $.ajax({
                url: "<?= base_url('submod/jsonlist') ?>",
                type: 'POST',
                dataType: 'json',
                data: m_modulo_id,
                success: function (msg) {
                    var sc = '';
                    sc += '<option value=""></option>';
                    $.each(msg, function (key, val) {
                        sc += '<option value="' + val.sm_sub_modulo_id + '">' + val.sm_nombre + '</option>';
                    });
                    $("#clear-sub-modulos option").remove();
                    $("#clear-materiales option").remove();
                    $("#clear-sub-modulos").append(sc);
                }
            });
        });
    });
    $(document).ready(function () {
        $('#clear-sub-modulos').change(function () {
            var sm_sub_modulo_id = {
                name: $('#clear-sub-modulos').val()
            };
            $.ajax({
                url: "<?= base_url('material/jsonlist') ?>",
                type: 'POST',
                dataType: 'json',
                data: sm_sub_modulo_id,
                success: function (msg) {
                    var sc = '';
                    sc += '<option value=""></option>';
                    $.each(msg, function (key, val) {
                        sc += '<option value="' + val.m_material_id + '">' + val.m_titulo + '</option>';
                    });
                    $("#clear-materiales option").remove();
                    $("#clear-materiales").append(sc);
                }
            });
        });
    });
</script>
<!-- Content -->
<div id="content">

    <!-- Content wrapper -->
    <div class="wrapper">

        <!-- Breadcrumbs line -->
        <div class="crumbs">
            <ul id="breadcrumbs" class="breadcrumb"> 
                <li><a href="<?= base_url('xpanel') ?>">XPANEL</a></li>
                <li class="active"><a href="<?= base_url() ?>" title="">Inicio</a></li>
            </ul>

        </div>
        <!-- /breadcrumbs line -->

        <!-- Page header -->
        <div class="page-header">
            <div class="page-title">
                <h5>XPANEL</h5>
            </div>

        </div>
        <!-- /page header -->

        <?php $mensaje ?>
        <?= form_open('evaluaciones/saveData', 'class="form-horizontal"') ?>
        <fieldset>

            <!-- General form elements -->
            <div class="widget row-fluid">
                <div class="navbar">
                    <div class="navbar-inner">
                        <h6>Alta de Evaluación</h6>
                    </div>
                </div>

                <div class="well">

                    <div class="control-group">
                        <label class="control-label">Empresa:</label>
                        <div class="controls">
                            <select name="e_empresa_id" data-placeholder="Seleccione..." id="clear-empresas" tabindex="2" required>
                                <option value=""></option> 
                                <?php foreach ($empresa as $e) { ?>
                                    <option value="<?= $e->e_empresa_id ?>"><?= $e->e_nombre ?></option> 
                                <?php } ?>
                            </select>
                        </div>             
                    </div>

                    <div class="control-group">
                        <label class="control-label">Divisiones:</label>
                        <div class="controls">
                            <select name="d_division_id" data-placeholder="Seleccione..." id="clear-divisiones" tabindex="2" required>
                                <option value=""></option> 
                            </select>
                        </div>             
                    </div>

                    <div class="control-group">
                        <label class="control-label">Módulo:</label>
                        <div class="controls">
                            <select name="m_modulo_id" data-placeholder="Seleccione..." id="clear-modulos" tabindex="2" required>
                                <option value=""></option> 

                            </select>
                        </div>             
                    </div>

                    <div class="control-group">
                        <label class="control-label">Sub-Módulo:</label>
                        <div class="controls">
                            <select name="sm_sub_modulo_id" data-placeholder="Seleccione..." id="clear-sub-modulos" tabindex="2" required>
                                <option value=""></option> 

                            </select>
                        </div>             
                    </div>
                    
                    <div class="control-group">
                        <label class="control-label">Material:</label>
                        <div class="controls">
                            <select name="m_material_id" data-placeholder="Seleccione..." id="clear-materiales" tabindex="2" required>
                                <option value=""></option> 

                            </select>
                        </div>             
                    </div>
                    
                    <div class="control-group">
                        <button type="submit" class="btn btn-primary">Submit</button>
                    </div>
                </div>
            </div>
            <!-- /general form elements -->

        </fieldset> 

        <?= form_close() ?>
        <!-- /basic inputs -->

    </div>
    <!-- /content wrapper -->

</div>
<!-- /content -->

